/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package iketest;

import java.text.SimpleDateFormat;

import java.util.ArrayList;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Pouja
 */
public class IKETest {
    static ArrayList<String> names;
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        names=new ArrayList<String>();
        String currentUser=null;
        User user=null;
        BigFile file;
        boolean continueL=false;
        while(true){
            try {

                file = new BigFile("dataset.csv");
                for(String line : file){

                    String[] tokens=line.split("\\t");
                    if(currentUser==null){
                        if(!names.contains(tokens[0])){
                            continueL=true;
                            currentUser=tokens[0];
                            user=new User(tokens[0]);
                        }
                    }
                    if(user!=null){
                        for(int i=0;i<tokens.length;i++){
                            if(tokens[i].trim().equals("")){
                                break;
                            }
                        }

                        if(!user.name().equals(tokens[0])){
                            break;
                        }
                        
                        SimpleDateFormat date=new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
                        Date songDate=date.parse(tokens[1]);
                        Song song=new Song(songDate,tokens[5],tokens[3]);
                        user.addSong(song);
                    }

                }
            } catch (Exception ex) {
                Logger.getLogger(IKETest.class.getName()).log(Level.SEVERE, null, ex);
            }
           
            user.createFile();
            System.out.println(user.name());

            names.add(user.name());
            currentUser=null;
            user=null;

            if(!continueL){
                break;
            }
            
        }
    }
}
